1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module gtk.TextTagTable; 26 27 private import glib.ConstructionException; 28 private import glib.Str; 29 private import gobject.ObjectG; 30 private import gobject.Signals; 31 private import gtk.BuildableIF; 32 private import gtk.BuildableT; 33 private import gtk.TextTag; 34 private import gtk.c.functions; 35 public import gtk.c.types; 36 private import std.algorithm; 37 38 39 /** 40 * The collection of tags in a `GtkTextBuffer` 41 * 42 * You may wish to begin by reading the 43 * [text widget conceptual overview](section-text-widget.html), 44 * which gives an overview of all the objects and data types 45 * related to the text widget and how they work together. 46 * 47 * # GtkTextTagTables as GtkBuildable 48 * 49 * The `GtkTextTagTable` implementation of the `GtkBuildable` interface 50 * supports adding tags by specifying “tag” as the “type” attribute 51 * of a <child> element. 52 * 53 * An example of a UI definition fragment specifying tags: 54 * ```xml 55 * <object class="GtkTextTagTable"> 56 * <child type="tag"> 57 * <object class="GtkTextTag"/> 58 * </child> 59 * </object> 60 * ``` 61 */ 62 public class TextTagTable : ObjectG, BuildableIF 63 { 64 /** the main Gtk struct */ 65 protected GtkTextTagTable* gtkTextTagTable; 66 67 /** Get the main Gtk struct */ 68 public GtkTextTagTable* getTextTagTableStruct(bool transferOwnership = false) 69 { 70 if (transferOwnership) 71 ownedRef = false; 72 return gtkTextTagTable; 73 } 74 75 /** the main Gtk struct as a void* */ 76 protected override void* getStruct() 77 { 78 return cast(void*)gtkTextTagTable; 79 } 80 81 /** 82 * Sets our main struct and passes it to the parent class. 83 */ 84 public this (GtkTextTagTable* gtkTextTagTable, bool ownedRef = false) 85 { 86 this.gtkTextTagTable = gtkTextTagTable; 87 super(cast(GObject*)gtkTextTagTable, ownedRef); 88 } 89 90 // add the Buildable capabilities 91 mixin BuildableT!(GtkTextTagTable); 92 93 94 /** */ 95 public static GType getType() 96 { 97 return gtk_text_tag_table_get_type(); 98 } 99 100 /** 101 * Creates a new `GtkTextTagTable`. 102 * 103 * The table contains no tags by default. 104 * 105 * Returns: a new `GtkTextTagTable` 106 * 107 * Throws: ConstructionException GTK+ fails to create the object. 108 */ 109 public this() 110 { 111 auto __p = gtk_text_tag_table_new(); 112 113 if(__p is null) 114 { 115 throw new ConstructionException("null returned by new"); 116 } 117 118 this(cast(GtkTextTagTable*) __p, true); 119 } 120 121 /** 122 * Add a tag to the table. 123 * 124 * The tag is assigned the highest priority in the table. 125 * 126 * @tag must not be in a tag table already, and may not have 127 * the same name as an already-added tag. 128 * 129 * Params: 130 * tag = a `GtkTextTag` 131 * 132 * Returns: %TRUE on success. 133 */ 134 public bool add(TextTag tag) 135 { 136 return gtk_text_tag_table_add(gtkTextTagTable, (tag is null) ? null : tag.getTextTagStruct()) != 0; 137 } 138 139 alias foreac = foreach_; 140 /** 141 * Calls @func on each tag in @table, with user data @data. 142 * 143 * Note that the table may not be modified while iterating 144 * over it (you can’t add/remove tags). 145 * 146 * Params: 147 * func = a function to call on each tag 148 * data = user data 149 */ 150 public void foreach_(GtkTextTagTableForeach func, void* data) 151 { 152 gtk_text_tag_table_foreach(gtkTextTagTable, func, data); 153 } 154 155 /** 156 * Returns the size of the table (number of tags) 157 * 158 * Returns: number of tags in @table 159 */ 160 public int getSize() 161 { 162 return gtk_text_tag_table_get_size(gtkTextTagTable); 163 } 164 165 /** 166 * Look up a named tag. 167 * 168 * Params: 169 * name = name of a tag 170 * 171 * Returns: The tag 172 */ 173 public TextTag lookup(string name) 174 { 175 auto __p = gtk_text_tag_table_lookup(gtkTextTagTable, Str.toStringz(name)); 176 177 if(__p is null) 178 { 179 return null; 180 } 181 182 return ObjectG.getDObject!(TextTag)(cast(GtkTextTag*) __p); 183 } 184 185 /** 186 * Remove a tag from the table. 187 * 188 * If a `GtkTextBuffer` has @table as its tag table, the tag is 189 * removed from the buffer. The table’s reference to the tag is 190 * removed, so the tag will end up destroyed if you don’t have 191 * a reference to it. 192 * 193 * Params: 194 * tag = a `GtkTextTag` 195 */ 196 public void remove(TextTag tag) 197 { 198 gtk_text_tag_table_remove(gtkTextTagTable, (tag is null) ? null : tag.getTextTagStruct()); 199 } 200 201 /** 202 * Emitted every time a new tag is added in the `GtkTextTagTable`. 203 * 204 * Params: 205 * tag = the added tag. 206 */ 207 gulong addOnTagAdded(void delegate(TextTag, TextTagTable) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 208 { 209 return Signals.connect(this, "tag-added", dlg, connectFlags ^ ConnectFlags.SWAPPED); 210 } 211 212 /** 213 * Emitted every time a tag in the `GtkTextTagTable` changes. 214 * 215 * Params: 216 * tag = the changed tag. 217 * sizeChanged = whether the change affects the `GtkTextView` layout. 218 */ 219 gulong addOnTagChanged(void delegate(TextTag, bool, TextTagTable) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 220 { 221 return Signals.connect(this, "tag-changed", dlg, connectFlags ^ ConnectFlags.SWAPPED); 222 } 223 224 /** 225 * Emitted every time a tag is removed from the `GtkTextTagTable`. 226 * 227 * The @tag is still valid by the time the signal is emitted, but 228 * it is not associated with a tag table any more. 229 * 230 * Params: 231 * tag = the removed tag. 232 */ 233 gulong addOnTagRemoved(void delegate(TextTag, TextTagTable) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 234 { 235 return Signals.connect(this, "tag-removed", dlg, connectFlags ^ ConnectFlags.SWAPPED); 236 } 237 }